<?php

/**
 * 分类预览 -> redis 修正脚本
 */

include_once 'index.php';

$newsModel = ModelNews::getInstance();
$newsTypes = $newsModel->getTypeList();
$redis = CacheRedis::getInstance();

if(!empty($newsTypes))
{
    foreach($newsTypes as $index => $type)
    {
        $tid = $type['id'];
        $key = Consts::KEYPREFIX_TID_COUNT . $tid;
        $name = $type['name'];
        $count = $newsModel->getTypeCount($type['id']);
        $redis->hMset(
            $key, [
                'tid' => $tid,
                'name' => $name,
                'count' => $count
            ]
        );
    }
}
